package com.itheima.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class ServletDemo02 extends HttpServlet {
//    @Override
//    public void init() throws ServletException {
//        System.out.println("被创建了");
//    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String path = req.getRequestURI();
        System.out.println(path);
        path=path.substring(path.lastIndexOf("/"));
        if ("/vip".equals(path)){
            System.out.println("7折");
        }else if ("/vvip".equals(path)) {
            System.out.println("8");
        }else
        {
            System.out.println("9折");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
